package com.ruoyi.web.controller.project;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.project.mapper.ProNoticeMapper;
import com.ruoyi.project.vo.ProNoticeEcharts;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/project/noticebing")
public class ProNoticeEchartsController extends BaseController {
    @Autowired
    private ProNoticeMapper proNoticeMapper;

    @GetMapping("/noticepie")
    public AjaxResult noticepie(){
        List<ProNoticeEcharts> pronotice = proNoticeMapper.selectNotice();
        ArrayList<ProNoticeEcharts> pronoticeEcharts = new ArrayList<>();
        for(ProNoticeEcharts echarts: pronotice){
            ProNoticeEcharts pronoticeEcharts1 = new ProNoticeEcharts();
            pronoticeEcharts1.setName(echarts.getName());
            pronoticeEcharts1.setValue(echarts.getValue());
            pronoticeEcharts.add(pronoticeEcharts1);
        }
        for(ProNoticeEcharts pronoticeEchart : pronoticeEcharts) {
            System.out.println("饼状图数据"+"=========="+pronoticeEchart.getName()+pronoticeEchart.getValue());
        }

        return AjaxResult.success(pronoticeEcharts);
    }
}
